{%include file="header.html"%}
<script type="text/javascript" src="{%$URL%}resource/laydate/laydate.js"></script>
<style>
table{text-align: center;}
th{text-align:center; font-weight: bolder;}
th a{ color:#000000;}
.firtd {	width: 100px;	padding-right: 10px;	text-align: right;}
input{width: 90px;}
textarea {	width: 350px;	height: 100px;}
#jin{
color:#f00;
}
#jin1{
color:#0D93BF;
}
</style>
<body>
<div class="fixed-bar">
  <div class="item-title">
    <h3>区域列表</h3>
      <div style="background:rgba(251,112,45,1);width:125px;height:40px;float:right;text-align:center;border-radius:5px;">
        <a href="quyu.php?act=edit">
          <h5 style="padding:10px;color:#fff;">添加区域</h5>
        </a>
      </div>
  </div> 
</div>
<div class="fixed_bottom">
  <form method="post" action="" id="aspnetForm" name="form1">
    <table align="center;" class="table tb-type2">
      <thead>
        <tr>
          <th width="50"><a>编号</a></th>
          <th width="25%"><a>区域名称</a></th>
          <th><a>添加时间</a></th>
          <th><a>是否开启</a></th>
          <th><a>操作</a></th>
        </tr>
      </thead>
      <tbody id="sortable">
        {%foreach from=$res item=list key=k%}
            <tr>
              <td>{%$list.r_id%}</td>
              <td>{%$list.r_name%}</td>
              <td><span>{%$list.r_time|date_format:'%Y-%m-%d %H:%M:%I'%}</span></td>
              <td>
                {%if $list.r_zt eq 1%}
                  <a href="javascript:;" id="jin" onclick="jy(this,{%$list.r_id%})">禁用</a>
                {%else%}
                  <a href="javascript:;" id="jin1" onclick="jy(this,{%$list.r_id%})">开启</a>
                {%/if%}

              </td>
              <td>
                <a href="quyu.php?act=edit&r_id={%$list.r_id%}">编辑</a> 
                <a href="#" onclick="del(this,{%$list.r_id%})">删除</a> 
              </td>
            </tr>
        {%/foreach%}
      </tbody>
    </table>
   <div class="page"></div>
  </form>
</div>
</body>
<script>
  function jy(obj,s_id){
  if($(obj).html()=='禁用'){
    var vals=1;
  }else{
    var vals=2;
  }
  $.post("quyu.php",{act:'disable',id:s_id,val:vals},function(data){
   if(data==1){
      layer.msg("操作成功！");
      if(vals==1){$(obj).html("开启");$(obj).css("color","#0D93BF");}else{$(obj).html("禁用");$(obj).css("color","#f00")}
    }else if(data==2){
      layer.msg("操作失败！");
    }
  })
}
function del(obj,r_id){
  $.post("quyu.php",{act:'del1',r_id:r_id},function(data){
      if(data=='1'){
        layer.msg("操作成功！",{},function(){
			$(obj).parents("tr").remove();
		});
      }else{
        layer.alert(data);
      }
  })
}
</script>
</html>